//
// Created by 95233 on 2024/4/30.
//

#include "ChessGame.h"
#include <iostream>

using namespace std;

ChessGame::ChessGame(Man *man, Ai *ai, Chess *chess) {
    this->mMan = man;
    this->mAi = ai;
    this->mChess = chess;
    mMan->init(mChess);
    mAi->init(mChess);
}

// 开始五子棋游戏
void ChessGame::startPlay() {
    cout << "游戏开始！" << endl;

    mChess->init();
    while (1) {
        // 先由棋手走棋
        mMan->go();
        if (mChess->checkOver()) {
            mChess->init();
            continue;
        }
        // Ai走
        mAi->go();
        if (mChess->checkOver()) {
            mChess->init();
            continue;
        }
    }
}

